package main

import "fmt"

type Describer interface {
	desc()
}

type ToString interface {
	toString()
}

type multInterface interface {
	Describer
	ToString
}

type Student struct {
	id int
	name string
}

// 使用值接收者
func (stu Student) desc()  {
	fmt.Printf("desc(): Student(id=%d, name=%s) \n", stu.id, stu.name)
}

func (stu Student) toString()  {
	fmt.Printf("toString(): Student(id=%d, name=%s) \n", stu.id, stu.name)
}

type Teacher struct {
	id int
	name string
}

// 使用指针接收者
func (t *Teacher) desc()  {
	fmt.Printf("Teacher(id=%d, name=%s) \n", t.id, t.name)
}

func main() {
	var describer1 Describer
	s1 := Student{1, "张三"}
	describer1 = s1
	describer1.desc()
	s2 := Student{2, "李四"}
	describer1 = s2
	describer1.desc()
	var describer2 Describer
	t1 := Teacher{1, "张老师"}
	describer2 = &t1
	describer2.desc()

	// 实现多个接口
	fmt.Println("实现多个接口")
	var d1 Describer = s1
	d1.desc()
	var d2 ToString = s1
	d2.toString()

	// 嵌套接口
	fmt.Println("嵌套接口")
	var d3 multInterface = s1
	d3.desc()
	d3.toString()


}
